﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectSubOffice.aspx.cs" Inherits="Meeting.Web.Admin.SelectBase.SelectSubOffice" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>选择分局信息</title>
      <script type="text/javascript" src="../../Scripts/jquery-1.8.2.min.js"></script>
    <!--树样式-->
    <link rel="stylesheet" href="../../Css/zTreeStyle/zTreeStyle.css" type="text/css" />
    <link rel="stylesheet" href="../../Css/main.css" type="text/css" />
    <script type="text/javascript" src="../../Scripts/jquery.ztree.core-3.5.min.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery.ztree.excheck-3.5.js"></script>
    <script type="text/javascript" src="../../Scripts/artDialog4.1.6/artDialog.js?skin=blue"></script>
    <script type="text/javascript" src="../../Scripts/artDialog4.1.6/plugins/iframeTools.js"></script>
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/cupertino/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="../../Css/main.css" />
    <script type="text/javascript" src="../../Scripts/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../Scripts/common.js"></script>


     <script type="text/javascript">
         var selCount = 0;
         var zTree;
         var CategoryId = "";
         //树初始化 
         var setting = { check: { enable: true },
             data: {
                 simpleData: {
                     enable: true,
                     idKey: "account",
                     pIdKey: "parent",
                     rootPId: ""
                 }
             }
         };

         $(function () {
             art.dialog.removeData('result');
             $.ajax({
                 type: "POST",
                 url: "../SelectBase/SelectOperation.ashx?method=GetSubOffice" ,
                 dataType: "json",
                 success: function (data, textStatus) {
                     //alert(data);
                     zTree = $.fn.zTree.init($("#treeMain"), setting, data);
                     zTree.expandAll(true);
                     zTree.setting.check.chkboxType = { "Y": "ps", "N": "ps" };

                 },
                 error: function (XMLHttpRequest, textStatus, errorThrown) {

                 }
             });
         }) 
       
         var selNodeJson = "";
         function GetCheckNode() {
             var nodes = zTree.getNodes();
             for (n = 0; n < nodes.length; n++) {
                 var t = nodes[n];
                 if (t.nodetype == "user" && t.checked == true) {

                     selNodeJson += ",{\"EmployeeId\":\"" + t.account + "\",\"EmployeeName\":\"" + t.name + "\",\"Mobile\":\"" + t.mobile + "\",\"RoleId\":\"" + t.parent + "\",\"EmployeeTitle\":\"" + t.title + "\",\"Sort\":10000}";
                 }
                 GetSubCheckNode(t);
             }
         }
         function GetSubCheckNode(node) {
             if (node == null) return;
             var nodes = node.children;
             if (nodes == undefined) return;
             //alert(nodes.length);
             for (i = 0; i < nodes.length; i++) {
                 var t = nodes[i];
                 if (t.nodetype == "user" && t.checked == true) {
                     selNodeJson += ",{\"EmployeeId\":\"" + t.account + "\",\"EmployeeName\":\"" + t.name + "\",\"Mobile\":\"" + t.mobile + "\",\"RoleId\":\"" + t.parent + "\",\"EmployeeTitle\":\"" + t.title + "\",\"Sort\":10000}";
                 }
                 GetSubCheckNode(t);
             }
         }

         function SelectOk() {

             GetCheckNode();
             if (selNodeJson.length > 0) selNodeJson = selNodeJson.substring(1);
             selNodeJson = "[" + selNodeJson + "]";
             //提交 
             art.dialog.data('result', "true");
             art.dialog.data('selNode', selNodeJson);
             art.dialog.close(); 
         }

    </script>
    <style type="text/css">
        input
        {
            border: 0;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div style="width: 450px; max-height: 350px; min-height: 170px; text-align: left;
            overflow: auto;">
            <ul id="treeMain" class="ztree">
            </ul>
        </div>
        <div style="text-align:right; margin-top:15px;">
            <a id="A1" class="easyui-linkbutton" onclick="SelectOk();">确定</a>
        </div>
    </div>
    </form>
</body>
</html>
